package com.oa.oaspcpersonalcenter.service.impl;



import com.oa.oaspccommon.po.User;
import com.oa.oaspcpersonalcenter.mapper.UserMapper;
import com.oa.oaspcpersonalcenter.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Sdx
 * 2021-04-15
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public User findUserByUsername(String username) {
        return userMapper.findUserByUsername(username);
    }

    @Override
    public User changePassword(String username) {
        return userMapper.changePassword(username);
    }

    @Override
    public List<User> findUsers() {
        return userMapper.findUsers();
    }

    @Override
    public User findUserByUid(int uid) {
        return userMapper.findUserByUid(uid);
    }

    @Override
    public boolean addUser(User user) {

        try {
            userMapper.addUser(user);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;

    }

    @Override
    public boolean updateUser(User user) {
        try {
            userMapper.updateUser(user);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean deleteUserByUid(int uid) {
        try {
            userMapper.deleteUserByUid(uid);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }


}
